package org.edu.modules.sxjy.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.edu.common.api.vo.Result;
import org.edu.modules.sxjy.entity.VeApply;
import org.edu.modules.sxjy.entity.VeBaseBanJi;
import org.edu.modules.sxjy.entity.VeBaseStudent;
import org.edu.modules.sxjy.entity.VeClassTeacher;
import org.edu.modules.sxjy.entity.VeCommon;
import org.edu.modules.sxjy.entity.VeCompany;
import org.edu.modules.sxjy.entity.VeCompanyUser;
import org.edu.modules.sxjy.entity.VePractice;
import org.edu.modules.sxjy.entity.VeResult;
import org.edu.modules.sxjy.entity.VeSumup;
import org.edu.modules.sxjy.feign.VeCommonClient;
import org.edu.modules.sxjy.mapper.VePracticeMapper;
import org.edu.modules.sxjy.mapper.VeResultMapper;
import org.edu.modules.sxjy.service.IVeApplyService;
import org.edu.modules.sxjy.service.IVeClassTeacharService;
import org.edu.modules.sxjy.service.IVeCompanyService;
import org.edu.modules.sxjy.service.IVeCompanyUserService;
import org.edu.modules.sxjy.service.IVePracticeService;
import org.edu.modules.sxjy.service.IVeResultService;
import org.edu.modules.sxjy.utils.DateUtils;
import org.edu.modules.sxjy.vo.VeResultEvaluationVo;
import org.edu.modules.sxjy.vo.VeResultInfoVo;
import org.edu.modules.sxjy.vo.VeResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class VeResultServiceImpl
        extends ServiceImpl<VeResultMapper, VeResult>
        implements IVeResultService
{
    @Autowired
    private VeResultMapper veResultMapper;
    @Autowired
    private IVeResultService veResultService;
    @Autowired
    private IVeApplyService veApplyService;
    @Autowired
    private IVeCompanyService veCompanyService;
    @Autowired
    private IVePracticeService vePracticeService;
    @Autowired
    private IVeCompanyUserService veCompanyUserService;
    @Autowired
    private IVeClassTeacharService veClassTeacharService;
    @Autowired
    private VePracticeMapper vePracticeMapper;
    @Autowired
    private VeCommonClient veCommonClient;

    public List<VeResultVo> selectAll(VeResultVo veResultVo, Integer pageNo, Integer pageSize, VeCommon veCommon)
    {
        List<VeResultVo> veResultVoList = new ArrayList();
        VeCompanyUser veCompanyUser;
        if (veCommon.getUserType().contains("0"))
        {
            veResultVoList = this.veResultMapper.selectAll(veResultVo, pageNo, pageSize, veCommon);
        }
        else if (veCommon.getUserType().equals("1"))
        {
            List<Integer> stuBjIdList = new ArrayList();

            List<VeClassTeacher> veClassTeacherList = this.veClassTeacharService.getBanjiIdByTeacherUserId(veCommon.getUserId());
            for (VeClassTeacher veClassTeacher : veClassTeacherList) {
                if ((veClassTeacher != null) && (!"".equals(veClassTeacher))) {
                    stuBjIdList.add(Integer.valueOf(veClassTeacher.getBjId()));
                }
            }
            veCommon.setStuBjId(stuBjIdList);
            veResultVoList = this.veResultMapper.selectAll(veResultVo, pageNo, pageSize, veCommon);
        }
        else if (veCommon.getUserType().equals("2"))
        {
            Object stuResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", veCommon.getUserId()).getResult();
            Map stuMap = (Map)stuResult;
            if (stuMap != null)
            {
                veCommon.setStuId(Integer.parseInt(stuMap.get("id").toString()));
                veResultVoList = this.veResultMapper.selectAll(veResultVo, pageNo, pageSize, veCommon);
            }
        }
        else if ((veCommon.getUserType().equals("4")) || (veCommon.getUserType().equals("3")))
        {
            veCompanyUser = this.veCompanyUserService.getCpInfoByUserId(veCommon.getUserId());
            veCommon.setCpId(veCompanyUser.getCpId());

            veResultVoList = this.veResultMapper.selectAll(veResultVo, pageNo, pageSize, veCommon);
        }
        if ((veResultVoList != null) && (veResultVoList.size() > 0)) {
            for (VeResultVo resultVo : veResultVoList)
            {
                if ((resultVo.getIsMark() == null) || ("".equals(resultVo.getIsMark()))) {
                    resultVo.setIsMark("评阅中");
                }
                if (resultVo.getSscore() != 0) {
                    resultVo.setIsMark("已评阅");
                }
                if ((veCommon.getUserType().equals("1")) &&
                        (resultVo.getScore() != 0)) {
                    resultVo.setIsMark("已评阅");
                }
                if ((veCommon.getUserType().equals("4")) &&
                        (resultVo.getCscore() != 0)) {
                    resultVo.setIsMark("已评阅");
                }
                if ("1".equals(resultVo.getIsMark())) {
                    resultVo.setIsMark("已评阅");
                } else if ("2".equals(resultVo.getIsMark())) {
                    resultVo.setIsMark("评阅中");
                }
                if ("1".equals(resultVo.getStatus())) {
                    resultVo.setStatus("已安排");
                } else if ("2".equals(resultVo.getStatus())) {
                    resultVo.setStatus("换岗");
                } else if ("3".equals(resultVo.getStatus())) {
                    resultVo.setStatus("已结束");
                } else {
                    resultVo.setStatus("已结束");
                }
                double cteacherProportion = this.veResultMapper.getCteacherProportion();
                double ctpro = cteacherProportion / 100.0D;
                resultVo.setCscore((int)Math.round(resultVo.getCscore() * ctpro));

                double steacherProportion = this.veResultMapper.getSteacherProportion();
                double stpro = steacherProportion / 100.0D;
                resultVo.setScore((int)Math.round(resultVo.getScore() * stpro));
                if ((resultVo.getCscore() != 0) && (resultVo.getScore() != 0)) {
                    resultVo.setSscore(resultVo.getCscore() + resultVo.getScore());
                }
                VePractice vePractice = this.veResultMapper.getprcByStuId(resultVo.getStuUserId());
                VeSumup veSumup = this.veResultMapper.getSumupByStuId(resultVo.getStuUserId());
                if ((vePractice != null) && (!"".equals(vePractice))) {
                    if (vePractice.getEndTime() < System.currentTimeMillis())
                    {
                        if ((veSumup != null) && (!"".equals(veSumup))) {
                            resultVo.setIsAssess("true");
                        } else {
                            resultVo.setIsAssess("false");
                        }
                    }
                    else {
                        resultVo.setIsAssess("false");
                    }
                }
            }
        }
        for (VeResultVo resultVo : veResultVoList)
        {
            VeApply veApply = this.veResultMapper.getStuApplyByStuUserId(resultVo.getStuUserId());
            if (veApply != null) {
                if (veApply.getType() == 2)
                {
                    VePractice practiceByStuUserId = this.vePracticeMapper.getPracticeByStuUserId(resultVo.getStuUserId());
                    resultVo.setName(practiceByStuUserId.getCpName());
                    resultVo.setPostName(practiceByStuUserId.getPostName());

                    resultVo.setStuIsFocusApper(2);
                }
                else if (veApply.getType() == 1)
                {
                    resultVo.setStuIsFocusApper(1);
                }
            }
        }
        return veResultVoList;
    }

    public List<VeResultVo> selectAlls(VeCommon veCommon)
    {
        List<VeResultVo> veResultVoList = this.veResultMapper.selectAlls(veCommon);
        if ((veResultVoList != null) && (!"".equals(veResultVoList))) {
            for (VeResultVo veResultVo : veResultVoList)
            {
                VeResult veResult = this.veResultMapper.getResultByStuUserId(veResultVo.getStuUserId());
                if ((veResult != null) && (!"".equals(veResult)))
                {
                    veResultVo.setScore(veResult.getScore());

                    veResultVo.setSscore(veResult.getSscore());

                    veResultVo.setCscore(veResult.getCscore());

                    veResultVo.setIsMark(String.valueOf(veResult.getIsMark()));
                }
                else
                {
                    veResultVo.setScore(0);

                    veResultVo.setSscore(0);

                    veResultVo.setCscore(0);

                    veResultVo.setIsMark("0");
                }
                if (veResultVo.getIsMark().equals("1")) {
                    veResultVo.setIsMark("已评阅");
                } else if (veResultVo.getIsMark().equals("2")) {
                    veResultVo.setIsMark("评阅中");
                }
                if (veResultVo.getStatus().equals("1")) {
                    veResultVo.setStatus("已安排");
                } else if (veResultVo.getStatus().equals("2")) {
                    veResultVo.setStatus("换岗");
                } else if (veResultVo.getStatus().equals("3")) {
                    veResultVo.setStatus("已结束");
                }
                double cteacherProportion = this.veResultMapper.getCteacherProportion();
                double ctpro = cteacherProportion / 100.0D;
                veResultVo.setCscore((int)Math.round(veResultVo.getCscore() * ctpro));

                double steacherProportion = this.veResultMapper.getSteacherProportion();
                double stpro = steacherProportion / 100.0D;
                veResultVo.setScore((int)Math.round(veResultVo.getScore() * stpro));
                if ((veResultVo.getCscore() != 0) && (veResultVo.getScore() != 0)) {
                    veResultVo.setSscore(veResultVo.getCscore() + veResultVo.getScore());
                }
            }
        }
        return veResultVoList;
    }

    public int getSumPage(VeResultVo veResultVo, VeCommon veCommon)
    {
        int pageNum = 0;
        if (veCommon.getUserType().contains("0"))
        {
            pageNum = this.veResultMapper.getSumPage(veResultVo, veCommon);
        }
        else if (veCommon.getUserType().equals("1"))
        {
            List<Integer> stuBjIdList = new ArrayList();

            List<VeClassTeacher> veClassTeacherList = this.veClassTeacharService.getBanjiIdByTeacherUserId(veCommon.getUserId());
            for (VeClassTeacher veClassTeacher : veClassTeacherList) {
                if ((veClassTeacher != null) && (!"".equals(veClassTeacher))) {
                    stuBjIdList.add(Integer.valueOf(veClassTeacher.getBjId()));
                }
            }
            veCommon.setStuBjId(stuBjIdList);
            if ((stuBjIdList != null) && (stuBjIdList.size() > 0)) {
                pageNum = this.veResultMapper.getSumPage(veResultVo, veCommon);
            } else {
                pageNum = 0;
            }
        }
        else if (veCommon.getUserType().equals("2"))
        {
            Object stuResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", veCommon.getUserId()).getResult();
            Map stuMap = (Map)stuResult;
            if (stuMap != null)
            {
                veCommon.setStuId(Integer.parseInt(stuMap.get("id").toString()));
                pageNum = this.veResultMapper.getSumPage(veResultVo, veCommon);
            }
        }
        else if ((veCommon.getUserType().equals("4")) || (veCommon.getUserType().equals("3")))
        {
            VeCompanyUser veCompanyUser = this.veCompanyUserService.getCpInfoByUserId(veCommon.getUserId());
            veCommon.setCpId(veCompanyUser.getCpId());

            pageNum = this.veResultMapper.getSumPage(veResultVo, veCommon);
        }
        return pageNum;
    }

    public VeResultInfoVo getOneInfo(int id, String userType, String userId)
    {
        VeResultInfoVo veResultInfoVo = new VeResultInfoVo();

        VePractice vePractice = (VePractice)this.vePracticeService.getById(Integer.valueOf(id));
        if ((vePractice == null) || ("".equals(vePractice))) {
            return veResultInfoVo;
        }
        VeResult veResult = this.veResultMapper.getResultByPrcId(id);
        if ((veResult == null) || ("".equals(veResult))) {
            return veResultInfoVo;
        }
        VeCompany veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(vePractice.getCpId()));

        Object stuResult = this.veCommonClient.getStudentById("09d5e1e7f9b049008eee645c783a1d67", vePractice.getStuUserId()).getResult();
        Map stuMap = (Map)stuResult;
        String s = JSON.toJSONString(stuMap);
        VeBaseStudent veBaseStudent = (VeBaseStudent)JSON.parseObject(s, VeBaseStudent.class);
        if ((veCompany != null) && (!"".equals(veCompany)))
        {
            veResultInfoVo.setXm(veBaseStudent.getXm());

            veResultInfoVo.setXbm(veBaseStudent.getXbm());

            veResultInfoVo.setXzbmc(this.veResultMapper.getXzbmc(vePractice.getBjId()));

            veResultInfoVo.setStartTime(DateUtils.getDateToString(((VePractice)this.vePracticeService.getById(Integer.valueOf(vePractice.getId()))).getStartTime()));

            veResultInfoVo.setCpName(veCompany.getName());

            veResultInfoVo.setAddress(veCompany.getAddress());

            veResultInfoVo.setTel(veCompany.getTel());

            veResultInfoVo.setLinkman(veCompany.getLinkman());

            VeCompanyUser veCompanyUser = this.veResultMapper.getCpUserByUserId(vePractice.getCteacherUserId());
            if (veCompanyUser != null)
            {
                veResultInfoVo.setRealName(veCompanyUser.getRealName());


                veResultInfoVo.setRealTel(veCompanyUser.getTel());
            }
            Integer teacherUserId = this.veResultMapper.getTeacherUserIdByStuUserId(vePractice.getStuUserId());
            if ((teacherUserId != null) && (!"".equals(teacherUserId)))
            {
                Object teacherResult = this.veCommonClient.getTeacherById("09d5e1e7f9b049008eee645c783a1d67", teacherUserId.intValue()).getResult();
                Map teacherMap = (Map)teacherResult;
                if ((teacherMap != null) && (!"".equals(teacherMap)))
                {
                    if (teacherMap.get("xm") != null) {
                        veResultInfoVo.setSteacherUserName(teacherMap.get("xm").toString());
                    }
                    if (teacherMap.get("lxdh") != null) {
                        veResultInfoVo.setLxdh(teacherMap.get("lxdh").toString());
                    }
                }
            }
            List<String> teacherList = this.veResultMapper.getTeacherIdByBjId(vePractice.getBjId());
            if ((teacherList != null) && (!"".equals(teacherList)))
            {
                Result<?> result = this.veCommonClient.getTeacherById("09d5e1e7f9b049008eee645c783a1d67", veResult.getSteacherUserId());
                if (result.getCode().equals(Integer.valueOf(200)))
                {
                    Object teacherResult = result.getResult();
                    Map teacherMap = (Map)teacherResult;
                    if ((teacherMap != null) && (!"".equals(teacherMap)))
                    {
                        veResultInfoVo.setSteacherUserName(teacherMap.get("xm").toString());
                        veResultInfoVo.setLxdh(teacherMap.get("lxdh").toString());
                    }
                }
            }
            veResultInfoVo.setCcomment(veResult.getCcomment());

            veResultInfoVo.setCscore(veResult.getCscore());
            if (veResult.getCverifyTime() != 0L) {
                veResultInfoVo.setCpIsCverify("已鉴定");
            } else {
                veResultInfoVo.setCpIsCverify("未鉴定");
            }
            if (veResult.getCverifyTime() != 0L) {
                veResultInfoVo.setCverifyTime(DateUtils.getDateToString(veResult.getCverifyTime()));
            }
            veResultInfoVo.setScomment(veResult.getScomment());

            veResultInfoVo.setScore(veResult.getScore());
            if (veResult.getSverifyTime() != 0L) {
                veResultInfoVo.setSIsSverify("已鉴定");
            } else {
                veResultInfoVo.setSIsSverify("未鉴定");
            }
            if (veResult.getSverifyTime() != 0L) {
                veResultInfoVo.setSverifyTime(DateUtils.getDateToString(veResult.getSverifyTime()));
            }
            double cteacherProportion = this.veResultMapper.getCteacherProportion();
            double ctpro = cteacherProportion / 100.0D;
            veResultInfoVo.setCpAutScore((int)Math.round(veResult.getCscore() * ctpro));

            double steacherProportion = this.veResultMapper.getSteacherProportion();
            double stpro = steacherProportion / 100.0D;
            veResultInfoVo.setTeacherAutScore((int)Math.round(veResult.getScore() * stpro));
            if ((veResultInfoVo.getCscore() != 0) && (veResultInfoVo.getScore() != 0)) {
                veResultInfoVo.setSscore(veResultInfoVo.getCpAutScore() + veResultInfoVo.getTeacherAutScore());
            }
            if ((veResultInfoVo.getCpAutScore() != 0) && (veResultInfoVo.getTeacherAutScore() != 0))
            {
                VeResult veResultEntity = (VeResult)this.veResultService.getById(Integer.valueOf(veResult.getId()));
                veResultEntity.setIsMark(1);
                veResultEntity.setSscore(veResultInfoVo.getSscore());
                this.veResultService.updateById(veResultEntity);
            }
        }
        return veResultInfoVo;
    }

    public VeResultEvaluationVo evaluationEcho(int id)
    {
        VePractice vePractices = (VePractice)this.vePracticeService.getById(Integer.valueOf(id));


        VeResultEvaluationVo veResultEvaluationVo = new VeResultEvaluationVo();
        if ((vePractices == null) && ("".equals(vePractices))) {
            return veResultEvaluationVo;
        }
        VeResult veResult = this.veResultMapper.getResultByPrcId(vePractices.getId());
        if (veResult == null)
        {
            VePractice vePractice = (VePractice)this.vePracticeService.getById(Integer.valueOf(id));
            List<VeCompanyUser> veCompanyUserList = this.veCompanyUserService.list();
            for (VeCompanyUser veCompanyUser : veCompanyUserList) {
                if (veCompanyUser.getUserId().equals(vePractice.getCteacherUserId())) {
                    veResultEvaluationVo.setCpTeacher(veCompanyUser.getRealName());
                }
            }
            Object stuResult = this.veCommonClient.getStudentById("09d5e1e7f9b049008eee645c783a1d67", vePractice.getStuUserId()).getResult();
            Map stuMap = (Map)stuResult;
            if ((stuMap != null) && (stuMap.size() > 0))
            {
                veResultEvaluationVo.setXm(stuMap.get("xm").toString());

                veResultEvaluationVo.setXbm(stuMap.get("xbm").toString());
            }
            Object specResult = this.veCommonClient.querySpecialtyById("09d5e1e7f9b049008eee645c783a1d67", Integer.valueOf(vePractice.getSpecId())).getResult();
            Map specMap = (Map)specResult;
            if ((specMap != null) && (specMap.size() > 0)) {
                veResultEvaluationVo.setPrcName(specMap.get("zymc").toString());
            }
            Result<?> banjiResult = this.veCommonClient.queryBanJiById("09d5e1e7f9b049008eee645c783a1d67", Integer.valueOf(vePractice.getBjId()));
            if (banjiResult.getCode().equals(Integer.valueOf(200)))
            {
                Object bjResult = banjiResult.getResult();
                Map bjMap = (Map)bjResult;
                if ((bjMap != null) && (!"".equals(bjMap)))
                {
                    String s = JSON.toJSONString(bjMap);
                    VeBaseBanJi veBaseBanJi = (VeBaseBanJi)JSON.parseObject(s, VeBaseBanJi.class);
                    veResultEvaluationVo.setBjName(veBaseBanJi.getXzbmc());
                }
            }
            veResultEvaluationVo.setStartTime(DateUtils.getDateToString(vePractice.getStartTime()));

            VeCompany veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(vePractice.getCpId()));
            if ((veCompany != null) && (!"".equals(veCompany)))
            {
                veResultEvaluationVo.setCpName(veCompany.getName());

                veResultEvaluationVo.setAddress(veCompany.getAddress());

                veResultEvaluationVo.setCpTel(veCompany.getTel());

                veResultEvaluationVo.setLinkman(veCompany.getLinkman());
            }
            VeCompanyUser veCompanyUser = this.veCompanyUserService.getCpInfoByUserId(vePractice.getCteacherUserId());
            if ((veCompanyUser != null) && (!"".equals(veCompanyUser)))
            {
                veResultEvaluationVo.setRealName(veCompanyUser.getRealName());

                veResultEvaluationVo.setCpUserTel(veCompanyUser.getTel());
            }
            List<String> teacherList = this.veResultMapper.getTeacherIdByBjId(vePractice.getBjId());
            if ((teacherList != null) && (!"".equals(teacherList)))
            {
                Result<?> result = this.veCommonClient.getTeacherById("09d5e1e7f9b049008eee645c783a1d67", veResult.getSteacherUserId());
                if (result.getCode().equals(Integer.valueOf(200)))
                {
                    Object teacherResult = result.getResult();
                    Map teacherMap = (Map)teacherResult;
                    if ((teacherMap != null) && (!"".equals(teacherMap)))
                    {
                        veResultEvaluationVo.setTeacherXm(teacherMap.get("xm").toString());
                        veResultEvaluationVo.setTeacherLxdh(teacherMap.get("lxdh").toString());
                    }
                }
            }
            return veResultEvaluationVo;
        }
        veResultEvaluationVo.setCscore(veResult.getCscore());


        veResultEvaluationVo.setCcomment(veResult.getCcomment());

        veResultEvaluationVo.setCscore(veResult.getCscore());
        if (veResult.getCverifyTime() != 0L) {
            veResultEvaluationVo.setCpEvaluation("已鉴定");
        } else if (veResult.getCverifyTime() == 0L) {
            veResultEvaluationVo.setCpEvaluation("未鉴定");
        }
        if (veResult.getCverifyTime() != 0L) {
            veResultEvaluationVo.setCverifyTime(DateUtils.getDateToString(veResult.getCverifyTime()));
        }
        veResultEvaluationVo.setScomment(veResult.getScomment());

        veResultEvaluationVo.setScore(veResult.getScore());
        if (veResult.getSverifyTime() != 0L) {
            veResultEvaluationVo.setCampusEvaluation("已鉴定");
        } else if (veResult.getSverifyTime() == 0L) {
            veResultEvaluationVo.setCampusEvaluation("未鉴定");
        }
        if (veResult.getSverifyTime() != 0L) {
            veResultEvaluationVo.setSverifyTime(DateUtils.getDateToString(veResult.getSverifyTime()));
        }
        veResultEvaluationVo.setCteacherProportion(this.veResultMapper.getCteacherProportion());
        double cteacherProportion = veResultEvaluationVo.getCteacherProportion();
        double ctpro = cteacherProportion / 100.0D;
        veResultEvaluationVo.setCpAutScore((int)Math.round(veResult.getCscore() * ctpro));

        veResultEvaluationVo.setSteacherProportion(this.veResultMapper.getSteacherProportion());
        double steacherProportion = veResultEvaluationVo.getSteacherProportion();
        double stpro = steacherProportion / 100.0D;
        veResultEvaluationVo.setTeacherAutScore((int)Math.round(veResult.getScore() * stpro));


        veResultEvaluationVo.setSscore(veResultEvaluationVo.getCpAutScore() + veResultEvaluationVo.getTeacherAutScore());
        if ((veResultEvaluationVo.getCpAutScore() != 0) && (veResultEvaluationVo.getTeacherAutScore() != 0))
        {
            VeResult veResultEntity = (VeResult)this.veResultService.getById(Integer.valueOf(veResult.getId()));
            veResultEntity.setIsMark(1);
            veResultEntity.setSscore(veResultEvaluationVo.getCpAutScore() + veResultEvaluationVo.getTeacherAutScore());

            this.veResultService.updateById(veResultEntity);
        }
        Result<?> banjiResult = this.veCommonClient.queryBanJiById("09d5e1e7f9b049008eee645c783a1d67", Integer.valueOf(vePractices.getBjId()));
        if (banjiResult.getCode().equals(Integer.valueOf(200)))
        {
            Object bjResult = banjiResult.getResult();
            Map bjMap = (Map)bjResult;
            if ((bjMap != null) && (!"".equals(bjMap)))
            {
                String s = JSON.toJSONString(bjMap);
                VeBaseBanJi veBaseBanJi = (VeBaseBanJi)JSON.parseObject(s, VeBaseBanJi.class);
                veResultEvaluationVo.setBjName(veBaseBanJi.getXzbmc());
            }
        }
        veResultEvaluationVo.setSpecComment(veResult.getSpecComment());

        Object specTeacherResult = this.veCommonClient.getTeacherById("09d5e1e7f9b049008eee645c783a1d67", veResult.getSpecUserId()).getResult();
        if ((specTeacherResult != null) && (!"".equals(specTeacherResult)))
        {
            Map specTeacherMap = (Map)specTeacherResult;
            veResultEvaluationVo.setSpecUserName(specTeacherMap.get("xm").toString());
        }
        if (veResult.getSpecVerifyTime() != 0L) {
            veResultEvaluationVo.setSpecVerifyTime(DateUtils.getDateToString(veResult.getSpecVerifyTime()));
        }
        Object stuResult = this.veCommonClient.getStudentById("09d5e1e7f9b049008eee645c783a1d67", veResult.getStuUserId()).getResult();
        Map stuMap = (Map)stuResult;
        if (stuMap.get("xm") != null) {
            veResultEvaluationVo.setXm(stuMap.get("xm").toString());
        }
        if (stuMap.get("xbm") != null) {
            veResultEvaluationVo.setXbm(stuMap.get("xbm").toString());
        }
        Object specResult = this.veCommonClient.querySpecialtyById("09d5e1e7f9b049008eee645c783a1d67", Integer.valueOf(veResult.getSpecId())).getResult();
        Map specMap = (Map)specResult;
        if (specMap.get("zymc") != null) {
            veResultEvaluationVo.setPrcName(specMap.get("zymc").toString());
        }
        veResultEvaluationVo.setStartTime(DateUtils.getDateToString(((VePractice)this.vePracticeService.getById(Integer.valueOf(veResult.getPrcId()))).getStartTime()));

        VeCompany veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(veResult.getCpId()));
        String cpName = veCompany.getName();
        if ((cpName != null) && (!"".equals(cpName))) {
            veResultEvaluationVo.setCpName(cpName);
        }
        String address = veCompany.getAddress();
        if ((address != null) && (!"".equals(address))) {
            veResultEvaluationVo.setAddress(address);
        }
        String tel = veCompany.getTel();
        if ((tel != null) && (!"".equals(tel))) {
            veResultEvaluationVo.setCpTel(tel);
        }
        String linkman = veCompany.getLinkman();
        if ((linkman != null) && (!"".equals(linkman))) {
            veResultEvaluationVo.setLinkman(linkman);
        }
        VeCompanyUser veCompanyUser = this.veCompanyUserService.getCpInfoByUserId(vePractices.getCteacherUserId());
        if ((veCompanyUser != null) && (!"".equals(veCompanyUser)))
        {
            veResultEvaluationVo.setRealName(veCompanyUser.getRealName());

            veResultEvaluationVo.setCpUserTel(veCompanyUser.getTel());
        }
        List<String> teacherList = this.veResultMapper.getTeacherIdByBjId(vePractices.getBjId());
        if ((teacherList != null) && (!"".equals(teacherList)))
        {
            Result<?> result = this.veCommonClient.getTeacherById("09d5e1e7f9b049008eee645c783a1d67", veResult.getSteacherUserId());
            if (result.getCode().equals(Integer.valueOf(200)))
            {
                Object teacherResult = result.getResult();
                Map teacherMap = (Map)teacherResult;
                if ((teacherMap != null) && (!"".equals(teacherMap)))
                {
                    veResultEvaluationVo.setTeacherXm(teacherMap.get("xm").toString());
                    veResultEvaluationVo.setTeacherLxdh(teacherMap.get("lxdh").toString());
                }
            }
        }
        return veResultEvaluationVo;
    }

    public Result<?> stuGradeEvaluation(VeResultEvaluationVo veResultEvaluationVo)
    {
        VePractice vePractice = (VePractice)this.vePracticeService.getById(Integer.valueOf(veResultEvaluationVo.getId()));

        List<VeResult> veResultList = this.veResultMapper.getResultByPrcIdList(vePractice.getId());
        if (veResultList.size() != 0)
        {
            VeResult veResults = (VeResult)veResultList.get(0);
            if (veResultEvaluationVo.getUserType().equals("1"))
            {
                Object teacherResult = this.veCommonClient.queryTeacherByUserId("09d5e1e7f9b049008eee645c783a1d67", veResultEvaluationVo.getUserId()).getResult();
                Map teacherMap = (Map)teacherResult;
                if ((teacherMap != null) && (!"".equals(teacherMap)))
                {
                    veResults.setScomment(veResultEvaluationVo.getScomment());

                    veResults.setScore(veResultEvaluationVo.getScore());

                    veResults.setSverifyTime(System.currentTimeMillis());

                    veResults.setUpdateTime(System.currentTimeMillis());

                    veResults.setSteacherUserId(Integer.parseInt(teacherMap.get("id").toString()));
                    if ((veResults.getScore() != 0) && (veResults.getCscore() != 0))
                    {
                        veResults.setSscore(veResults.getScore() + veResults.getCscore());
                        veResults.setIsMark(1);
                    }
                    this.veResultService.updateById(veResults);
                    return Result.ok("评定成功");
                }
            }
            else if (veResultEvaluationVo.getUserType().equals("4"))
            {
                veResults.setCcomment(veResultEvaluationVo.getCcomment());

                veResults.setCscore(veResultEvaluationVo.getCscore());

                veResults.setCverifyTime(System.currentTimeMillis());

                veResults.setUpdateTime(System.currentTimeMillis());
                if ((veResults.getScore() != 0) && (veResults.getCscore() != 0))
                {
                    veResults.setSscore(veResults.getScore() + veResults.getCscore());
                    veResults.setIsMark(1);
                }
                this.veResultService.updateById(veResults);
                return Result.ok("评定成功");
            }
        }
        else
        {
            VeResult veResults = new VeResult();


            int stuUserId = vePractice.getStuUserId();
            if (stuUserId != 0) {
                veResults.setStuUserId(stuUserId);
            }
            if (veResultEvaluationVo.getUserType().equals("1"))
            {
                Object teacherResult = this.veCommonClient.queryTeacherByUserId("09d5e1e7f9b049008eee645c783a1d67", veResultEvaluationVo.getUserId()).getResult();
                Map teacherMap = (Map)teacherResult;
                if (teacherMap != null)
                {
                    veResults.setScore(veResultEvaluationVo.getScore());

                    veResults.setScomment(veResultEvaluationVo.getScomment());
                    if (veResults.getScore() != 0) {
                        veResults.setSverifyTime(System.currentTimeMillis());
                    }
                    veResults.setSteacherUserId(Integer.parseInt(teacherMap.get("id").toString()));
                }
            }
            else if (veResultEvaluationVo.getUserType().equals("4"))
            {
                veResults.setCscore(veResultEvaluationVo.getCscore());

                veResults.setCcomment(veResultEvaluationVo.getCcomment());

                veResults.setCteacherUserId(veResultEvaluationVo.getUserId());
                if (veResults.getCscore() != 0) {
                    veResults.setCverifyTime(System.currentTimeMillis());
                }
            }
            veResults.setSscore(veResultEvaluationVo.getSscore());



            veResults.setSpecComment(veResultEvaluationVo.getSpecComment());





            veResults.setPrcId(vePractice.getId());

            veResults.setFalId(vePractice.getFalId());

            veResults.setSpecId(vePractice.getSpecId());

            veResults.setIsMark(2);

            veResults.setMarkTime(System.currentTimeMillis());

            veResults.setCreateTime(System.currentTimeMillis());

            veResults.setUpdateTime(System.currentTimeMillis());

            veResults.setBjId(vePractice.getBjId());

            veResults.setCpId(vePractice.getCpId());

            veResults.setPostId(vePractice.getPostId());

            veResults.setTerminalId(1);
            if ((veResults.getScore() != 0) && (veResults.getCscore() != 0))
            {
                veResultEvaluationVo.setCteacherProportion(this.veResultMapper.getCteacherProportion());
                double cteacherProportion = veResultEvaluationVo.getCteacherProportion();
                double ctpro = cteacherProportion / 100.0D;
                veResultEvaluationVo.setCpAutScore((int)Math.round(veResults.getCscore() * ctpro));

                veResultEvaluationVo.setSteacherProportion(this.veResultMapper.getSteacherProportion());
                double steacherProportion = veResultEvaluationVo.getSteacherProportion();
                double stpro = steacherProportion / 100.0D;
                veResultEvaluationVo.setTeacherAutScore((int)Math.round(veResults.getScore() * stpro));

                veResults.setSscore(veResultEvaluationVo.getCpAutScore() + veResultEvaluationVo.getTeacherAutScore());
                veResults.setIsMark(1);
            }
            this.veResultService.save(veResults);
            return Result.OK("提交成功");
        }
        return Result.OK();
    }
}
